package com.tanhua.admin.mapper;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.tanhua.model.db.Log;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

/**
 * @auther : 白月尘
 * @date : 13:27  2021/10/28
 */
public interface LogMapper extends BaseMapper<Log> {
    @Select("SELECT count(user_Id) from tb_log where log_time = #{logTime} and type =#{type}")
    Integer queryByTypeAndLogTime(@Param("type") String type, @Param("logTime") String logTime);

    @Select("SELECT count(DISTINCT user_Id) from tb_log where log_time = #{logTime}")
    Integer queryByLogTime(String logTime);

    @Select("SELECT count(DISTINCT user_Id) from tb_log where log_time > #{logTime}")
    Integer queryByGtLogTime(String logTime);

    @Select("SELECT count(DISTINCT user_id) from tb_log where log_time =#{today} " +
            "and user_id in (SELECT user_id FROM tb_log WHERE type='0102' and log_time = #{yesterday})")
    Integer queryMumRetention1d(@Param("today") String today, @Param("yesterday") String yesterday);
    @Select("SELECT SUM(num_registered) from tb_analysis; ")
    Integer findAll();
}
